drivers/char: fix handling cable re-plug in XHCI console driver
authorMarek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Mon, 26 Sep 2022 09:12:39 +0000 (11:12 +0200)
committerJan Beulich <jbeulich@suse.com>
Mon, 26 Sep 2022 09:12:39 +0000 (11:12 +0200)
commit7aadb75e286df576278c20257936e53a348d23ee
treecaa95e2e9452442f5bfe6e0670a741b5eec41e1f
parentd88e2aa4eafcec282554042e49e2bac001c9bd6e
drivers/char: fix handling cable re-plug in XHCI console driver

When cable is unplugged, dbc_ensure_running() correctly detects this
situation (DBC_CTRL_DCR flag is clear), and prevent sending data
immediately to the device. It gets only queued in work ring buffers.
When cable is plugged in again, subsequent dbc_flush() will send the
buffered data.
But there is a corner case, where no subsequent data was buffered in the
work buffer, but a TRB was still pending. Ring the doorbell to let the
controller re-send them. For console output it is rare corner case (TRB
is pending for a very short time), but for console input it is very
normal case (there is always one pending TRB for input).

Extract doorbell ringing into separate function to avoid duplication.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
xen/drivers/char/xhci-dbc.c